<template>
	<view>
		<cover-view class="body" v-show="networkType">
			<cover-image src="/static/image/i_nothing.png" mode="aspectFill"></cover-image>
			<cover-view>网络中断，请刷新重试</cover-view>
		</cover-view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				networkTypeTemp: ''
			};
		},
		computed: {
			networkType() {
				if (this.networkTypeTemp == 'none' && this.$store.state.networkTypeTemp != 'none') {
					// let routes = getCurrentPages()
					// let page = routes[routes.length - 2]
					// let curRoute = page.route // 获取当前页面路由，也就是最后一个打开的页面路由
					// let url = ''
					// if(page.options){
					// 	let index = 0
					// 	for (let key in page.options) {
					// 		let k = ''
					// 		if (index == 0) {
					// 			k = '?'
					// 		} else {
					// 			k = '&'
					// 		}
					// 		url += (k + key + '=' + page.options[key])
					// 		index++
					// 	}
					// }					
					// url = '/' + curRoute + url
					// console.log('路径---------',url);
					// //重新加载页面数据
					// uni.redirectTo({
					// 	url
					// })
					// url = null
					// curRoute = null
					
					//获取页面栈的长度
					const canNavBack = getCurrentPages()
					console.log(canNavBack.length);
					// 判断是否刷新了浏览器，刷新了浏览器，页面栈只有当前一个 
					if ( canNavBack.length > 1) {
						uni.navigateBack({
							delta: 1
						})
					} else {
						uni.switchTab({
							url:'/pages/index/index'
						})
					}
				}
				this.networkTypeTemp = this.$store.state.networkType
				if (this.$store.state.networkType == 'none') {
					return true
				}
				return false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.body {
		position: fixed;
		top: 0;
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		background-color: #f6f6f6;
		z-index: 99;

		cover-image {
			width: 280rpx;
			height: 165rpx;
		}

		cover-view {
			font-size: 28rpx;
			color: #C1C1C1;
			margin-top: 32rpx;
		}
	}
</style>
